#ifndef RMGRIPPER_H
#define RMGRIPPER_H
#include "queryserial.h"

#define RETURN_ORIGINAL_REGISTER_ADDR   (0x0579)
#define STOP_CONTROL_REGISTER_ADDR      (0x057D)

#define INSTRUCTION_FUN_READ                                 (0x03)
#define INSTRUCTION_FUN_WRITE                                (0x10)

#define INSTRUCTION0_REGISTER_BASE_ADDR                      (0x1388)
#define INSTRUCTION_REGISTER_ADDR_TYPE_OFFSET                (0x0)
#define INSTRUCTION_REGISTER_ADDR_LOCATION_OFFSET            (0x02)
#define INSTRUCTION_REGISTER_ADDR_SPEED_OFFSET               (0x04)
#define INSTRUCTION_REGISTER_ADDR_ACC_OFFSET                 (0x06)
#define INSTRUCTION_REGISTER_ADDR_DEC_OFFSET                 (0x08)
#define INSTRUCTION_REGISTER_ADDR_PUSH_FORCE_OFFSET          (0x0C)
#define INSTRUCTION_REGISTER_ADDR_PUSH_DIST_OFFSET           (0x0E)

#define INSTRUCTION_REGISTER_ADDR_NEXT_OFFSET                (0x12)

class RmGripper
{
public:
    RmGripper();
    ~RmGripper();
    int init();
    int return_to_original();                       //回原点
    int stop();                                     //停止运动
    int trigger_num0_pushing_motion();              //触发序号0推压运动
    int set_num0_pushing_motion();                  //设置序号0推压运动参数
private:
    QuerySerial query_serial;
    int cmd_send_and_check(char* cmd_buf,char buf_size);
    int assemble_instruction_cmd(char *cmd_buf, char fun, short addr, short num, \
                                 char *data, char data_size);
    int send_instruction_cmd(char *cmd_buf, int buf_size);

};

#endif // RMGRIPPER_H
